﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;


namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class CTDatHangOnlineBlo
    {
         #region "Khai báo các biến"
        private CTDatHangOnlineDAO da;
        private CTDatHangOnlineDTO _CTDHOL;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public CTDatHangOnlineDTO CTDHOL
        {
            get { return _CTDHOL; }
            set { _CTDHOL = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public CTDatHangOnlineBlo()
        {            
            da = new CTDatHangOnlineDAO();
        }
        public bool InsertCTDHOL(string MaDHOL,string MaMH,int SoLuong,double DonGia,float KhuyenMai,double ThanhTien)
        {
            _CTDHOL = new CTDatHangOnlineDTO(MaDHOL, MaMH, SoLuong, DonGia, KhuyenMai,ThanhTien);
            if (!da.InsertCTDHOL(CTDHOL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTDHOL(string MaDHOL, string MaMH, int SoLuong, double DonGia, float KhuyenMai,double ThanhTien)
        {
            _CTDHOL = new CTDatHangOnlineDTO(MaDHOL, MaMH, SoLuong, DonGia, KhuyenMai,ThanhTien);
            if (!da.UpdateCTDHOL(CTDHOL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTDHOL(string MaDHOL, string MaMH)
        {
            if (!da.DeleteCTDHOL(MaDHOL,MaMH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_CTDatHangOnline()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTDatHangOnline();
            return ds;
        }
        #endregion 
    }
}